package cn.yunhe.interceptor;

import cn.yunhe.controller.CountAction;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.AbstractInterceptor;
import lombok.Data;

@Data
public class CountInterceptor extends AbstractInterceptor {
    @Override
    public String intercept(ActionInvocation invocation) throws Exception {

        CountAction countAction = (CountAction) invocation.getAction();
        if (invocation.getProxy().getMethod().equals("chu") && countAction.getNum2() == 0) {
            countAction.setResult("error");
            return null;
        } else {
            return invocation.invoke();
        }
    }
}
